Engine = {}
local Engine_mt = Class(Engine)

function Engine:new(unitID,unitDefID,teamID)
return setmetatable( 	{
						Engines	 = {},
						},
						Engine_mt
					)
end					

function Engine:registerEngine(unitID,unitDefID,teamID)
self.Engines[teamID]	= {
							unitID 		= unitID,
							unitDefID 	= unitDefID,
							experience	= 0,
							level 		= 0,
							upgrades	= {
											damage 	= 0,
											weapon 	= 0,
											speed	= 0,
											health	= 0,
											},
							abilities	= {
											cloak 	= 0,
											jump 	= 0,
											rage 	= 0,
											emp 	= 0,
											repair 	= 0,
											},
							isAlive 	= true,
							}
return						
end

function Engine:create(unitDef, x, y, z, facing, teamID, blocking)
getfenv(0).AllowUnsafeChanges("USE AT YOUR OWN PERIL")
local unitID = Spring.CreateUnit(unitDef, x, y, z, facing, teamID)
Spring.SetUnitLineage(unitID, teamID, false)
Spring.SetUnitBlocking(unitID, blocking)	
getfenv(0).AllowUnsafeChanges("Turn OFF")
self.Engines[teamID].isAlive = true
self.Engines[teamID].unitID = unitID
end

function Engine:died(teamID)
self.Engines[teamID].isAlive = false
return
end

function Engine:changeExperience(amount, teamID)
self.Engines[teamID].experience = self.Engines[teamID].experience + amount
return
end

function Engine:addAbility(teamID, ability, level)
self.Engines[teamID].abilities.ability = level
return
end

function Engine:addUpgrade(teamID, upgrade, level)
self.Engines[teamID].upgrades.upgrade = level
return
end